//
//  KYAppInfoDetailViewContoller.m
//  ipa_dumper491
//
//  Created by philip on 12/9/15.
//  Copyright © 2015 7659. All rights reserved.
//

#import "KYAppInfoDetailViewContoller.h"
#import "dump.h"

@interface KYAppInfoDetailViewContoller ()
@property (weak, nonatomic) IBOutlet UITextField *txtName;
@property (weak, nonatomic) IBOutlet UITextField *txtBundleIdentifier;
@property (weak, nonatomic) IBOutlet UITextField *txtBundleExecutable;
@property (weak, nonatomic) IBOutlet UITextView *txtBundleURL;
@property (weak, nonatomic) IBOutlet UITextView *txtStatus;
@property (weak, nonatomic) IBOutlet UITextView *txtDataContainerURL;
@end

@implementation KYAppInfoDetailViewContoller
- (IBAction)genIPA:(id)sender {
    dispatch_async(dispatch_get_main_queue(), ^(){
        int success = dumpIPA(self.detailInfo.bundleURLString, self.txtName.text);
        if (success) {
            self.txtStatus.text = [NSString stringWithFormat:@"success, saved as Documents/%@.ipa", self.txtName.text];
        }else{
            self.txtStatus.text = @"dump Failed!";
        }
    });
}

-(void)viewDidLoad
{
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"应用详情";
    if ([self detailInfo]) {
        self.txtName.text = self.detailInfo.Name;
        self.txtBundleIdentifier.text = self.detailInfo.bundleIdentifier;
        self.txtBundleURL.text = self.detailInfo.bundleURLString;
        self.txtBundleExecutable.text = self.detailInfo.bundleExecutable;
        self.txtDataContainerURL.text = self.detailInfo.dataContainerURLString;
    }
}
@end
